import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import resolve from "path";
import viteCompression from "vite-plugin-compression";

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    react(),
      {
        name:'my-plu',
        transform(code){
          return code.replace(/console\.log/g,'console.info')
        }
      },
      viteCompression({
        verbose:true,
        disable:false,
        threshold:10240,
        algorithm:'gzip',
        ext:'.gz'
      })
  ],
  resolve: {
    alias: {
      "@": resolve.resolve(__dirname, "src")
    }
  },
  server: {
    host: '0.0.0.0',
    port: 3050,
    open: true,
    proxy: {
      '/api': {
        target: 'http://blogapi.shbwyz.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      }
    }
  }
})
